package com.hejia.alauda.persistence.mybatis;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.hejia.alauda.entity.PayGateBank;
import com.hejia.alauda.persistence.BaseMapper;

public interface PayGateBankMapper extends BaseMapper<PayGateBank> {

	@Delete("delete from `paygatebank` where paygateid = #{0}")
	public boolean deletePayGateBankByPid(Long pid);

	/**
	 * 查询支付网关银行
	 * @param payGateCode	支付网关编码
	 * @param payBankCode	银行编码
	 * @return	支付网关银行
	 */
	@Select("select * from paygatebank b join paygate g on b.paygateid = g.id" 
			+ " where g.gatecode = #{payGateCode} and b.payBankCode = #{payBankCode}")
	public PayGateBank selectPayGateBankByCode(
			@Param("payGateCode") String payGateCode,
			@Param("payBankCode") String payBankCode);

	/**
	 * 根据支付网关代码查询银行
	 * @param payGateCode	支付网关代码
	 * @return
	 */
	@Select("SELECT b.* FROM paygatebank b join paygate g on b.paygateid = g.id where g.gatecode = #{payGateCode}")
	public List<PayGateBank> findPayGateBanksByPayGateCode(@Param("payGateCode") String payGateCode);

}
